/**
 * Configures the Team Site form
 * @returns Boolean True upon success, false upon failure
 */
function init (settings) {

	var Core = this;				// The core extension
	var form = $("#teamsite");		// The current form

	// Apply application customization
	
	$("#ts_reset").click (function () {
		if (Core.TeamSite) {
			if (Core.TeamSite.URL == form.fields ("ts_url").val ()) {
				alert ("This is the current Team Site.");
			} else {
				form.fields ("ts_url").val (Core.TeamSite.URL);
			}
		} else {
			if (confirm ("There is currently no Team Site configured.\nUse the default SharePoint connection?")) {
				form.fields ("ts_url").val (SharePoint.URL);
				form.submit ();
			}
		}
	});
	
	form.fields("ts_url").change (function () {
		var url = $(this).val();
		$("#ts_home").attr ('href', url);
		$("#ts_ws").attr ('href', url + "_layouts/1033/mngsubwebs.aspx?view=dws");
		$("#ts_config").attr ('href', url + "_layouts/1033/settings.aspx");
		$("#ts_admin").attr ('href', url + "_layouts/1033/webadmin.aspx");
	});

	// Process the Team Site form
	form.submit(function () {
		
		// Try to connect to the Team Site
		var TeamSiteURL = form.fields("ts_url").val();
		var NewTeamSite = new TeamSite (TeamSiteURL);
		
		// Check if the connection was successful
		if (NewTeamSite) {
			Core.TeamSite = NewTeamSite;
			Log.inform ('Active Team Site has been changed to <a href="' + Core.TeamSite.URL + '"  target="_blank">' + Core.TeamSite.Name + "</a>");
		} else {
			Log.warn ('Could not change Team Site to target <a href="' + TeamSiteURL + '"  target="_blank">' + TeamSiteURL + "</a>.'");
		}
		
		// This is an asynchronous operation
		return false;
	});
	
	// Finish initialization
	return true;
}